# -*- coding:utf-8 -*-
import uvicorn as uvicorn
from fastapi import FastAPI
from loguru import logger
import predict_bert as predict

log_path = '/data/logs/text-to-punctuation/app_{time:YYYYMMDD}.log'
logger.add(log_path, format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}", filter="app", level="INFO", rotation="10 MB", retention='7 days', compression='zip', encoding='utf-8')

app = FastAPI()

@app.get('/text/to/punctuation')
def fun(text: str) -> str:
    logger.info('Enter method text to punctuation and the param text is {}', text)
    sentence = predict.punc('也就是对象的容器这样说有助于你的理解啦也就是说我们这里是有两个对象')
    return sentence

if __name__ == '__main__':
    predict.punc('') #初始化加载模型
    uvicorn.run(app=app, host="0.0.0.0", port=8000)



  
